package org.company.management;

import org.company.management.utilities.Strings;
import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.StatusLineContributionItem;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

/**
 * @author Paner
 *
 */
public class ApplicationActionBarAdvisor extends ActionBarAdvisor {
	
	// Actions - important to allocate these only in makeActions, and then use them
    // in the fill methods.  This ensures that the actions aren't recreated
    // when fillActionBars is called with FILL_PROXY.
    private IWorkbenchAction _exitAction;
    private IWorkbenchAction _aboutAction;

    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    protected void makeActions(IWorkbenchWindow window) {
    	// Creates the actions and registers them.
        _exitAction = ActionFactory.QUIT.create(window);
        register(_exitAction);
       
        _aboutAction = ActionFactory.ABOUT.create(window);
        register(_aboutAction);
    }

    protected void fillMenuBar(IMenuManager menuBar) {
    	MenuManager fileMenu = new MenuManager(Strings.applicationName, IWorkbenchActionConstants.M_FILE);
        MenuManager helpMenu = new MenuManager(Strings.help, IWorkbenchActionConstants.M_HELP);
       
        menuBar.add(fileMenu);
        // Add a group marker indicating where action set menus will appear.
        menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
        menuBar.add(helpMenu);
       
        fileMenu.add(_exitAction);
       
        // Help
        helpMenu.add(_aboutAction);
    }
    
    @Override
    protected void fillStatusLine(IStatusLineManager statusLine)
    {
	    StatusLineContributionItem statusItem = new StatusLineContributionItem(Strings.loggedInStatus);
	    statusItem.setText(Strings.loggedIn);
	    statusLine.add(statusItem);

    }
    
}
